<template>
	<view class="uni-content">
		<uni-section title="账号信息" type="line">
			<template v-slot:right>
				<text style="color: #ff6600;" @click="navigateToFun('/pages/ucenter/userinfo/loginInfo')">编辑</text>
			</template>
			<uni-list :border="true">
				<uni-list-item :border="false" title="账号" :rightText="userInfo.name" />
				<uni-list-item :border="false" title="昵称" :rightText="userInfo.nickName" />
				<uni-list-item :border="false" title="性别" :rightText="userInfo.sex && userInfo.sex != 0 ?userInfo.params.sexName:'未设置'" />
				<uni-list-item :border="false" title="邮箱" :rightText="userInfo.email?userInfo.email:'未设置'" />
				<uni-list-item :border="false" title="手机号" :rightText="userInfo.phonenumber" />
			</uni-list>
		</uni-section>
		<uni-section class="mt10 mb20" title="学生信息" type="line">
			<template v-slot:right>
				<text style="color: #ff6600;" @click="navigateToFun('/pages/ucenter/userinfo/stuInfo?regionCode=' + stuInfo.regionCode + '&score=' + stuInfo.score + '&bizUniSubject=' + stuInfo.bizUniSubject + '&id=' + stuInfo.id)">编辑</text>
			</template>
			<uni-list :border="true">
				<uni-list-item :border="false" title="分数" :rightText="stuInfo.score? stuInfo.score + ' 分' : '未设置'" />
				<uni-list-item :border="false" title="排名" :rightText="(stuInfo.rankNum || '未设置')+''" />
				<uni-list-item :border="false" title="选科" :rightText="stuInfo.subjectName || '未设置'" />
			</uni-list>
		</uni-section>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				stuInfo: {
					id: "",
					regionCode: "",
					score: "",
					bizUniSubject: ""
				}
			}
		},
		onShow() {
			if (this.$isLogin(true)) {
				this.$syncUserInfo().then(()=>{
					this.userInfo = uni.getStorageSync('gkms-userInfo');
					this.stuInfo = uni.getStorageSync('gkms-stuInfo')
				})
			}
		},
		methods: {
			navigateToFun(url) {
				uni.navigateTo({
					url: url,
					fail(e) {
						console.error(e);
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "../common/style/uc-common.scss";
</style>
